<?php
/* ========== ########## ========== ########## ========== ########## ========== */
/*                                                                              */
/*   WHMCS v4.1.2 NULLED R4 by FLIPMODE  [ BAD SYNTAX ]                         */
/*                                                                              */
/*                             INTERNAL BAD SYNTAX NULLED VERSION: 2.5.9.6 R4   */
/*                                                                              */
/*   ALL files have been analysed, cleaned and nulled of:                       */
/*     - Call Backs  (100%)                                                     */
/*     - Link Backs (95%)                                                       */
/*     - Licensing  (100%)                                                      */
/*     - Remote Links + URL's                                                   */
/*                                                                              */
/*   WHMCS v4.1.2 RELEASED: 4th November 2009                                   */
/*    -> FIRST v4.1.2 NULL R1: 19th November 2009                               */
/*    -> UPDATED v4.1.2 NULL R4: 27th November 2009                             */
/*                                                                              */
/*   TESTING + VERIFICATION::                                                   */
/*     Files Cleaned, Nulled, Checked, Verified By:                             */
/*      -> FLIPMODE!                                                            */
/*     Decoded By:                                                              */
/*      -> FLIPMODE! + Unknown Decoder                                          */
/*     Tested By:                                                               */
/*      -> FLIPMODE!, LeetWolf, and 12 Anonymous Users...                       */
/*     WHMCS 4.1.2 Supplied By:                                                 */
/*      -> WHM CompleteShit Coder @ WHMCS.com                                   */
/*                                                                              */
/*                                                                              */
/*   IMPORTANT NOTE::                                                           */
/*   PLEASE NOTE THIS IS FOR TRIAL PURPOSES ONLY!                               */
/*                          LIKE IT? THEN BUY IT!                               */
/*                                                                              */
/* ========== ########## ========== ########## ========== ########## ========== */

function htmlspecialchars_array ($arr)
{
	$cleandata = array ();
	if (is_array ($arr))
	{
		foreach ($arr as $key => $val)
		{
			if (is_array ($val))
			{
				$cleandata[$key] = htmlspecialchars_array ($val);
				continue;
			}
			else
			{
				$cleandata[$key] = htmlspecialchars ($val);
				if (get_magic_quotes_gpc ())
				{
					$cleandata[$key] = stripslashes ($cleandata[$key]);
					continue;
				}

				continue;
			}
		}
	}
	else
	{
		$cleandata = htmlspecialchars ($arr);
		if (get_magic_quotes_gpc ())
		{
			$cleandata = stripslashes ($cleandata);
		}
	}

	return $cleandata;
}







                        function checkip ($ip)
                        {
                        	if (((!empty ($ip) AND ip2long ($ip) != 0 - 1) AND ip2long ($ip) != false))
                        	{
                        		$private_ips = array (array ('0.0.0.0', '2.255.255.255'), array ('10.0.0.0', '10.255.255.255'), array ('127.0.0.0', '127.255.255.255'), array ('169.254.0.0', '169.254.255.255'), array ('172.16.0.0', '172.31.255.255'), array ('192.0.2.0', '192.0.2.255'), array ('192.168.0.0', '192.168.255.255'), array ('255.255.255.0', '255.255.255.255'));
                        		foreach ($private_ips as $r)
                        		{
                        			$min = ip2long ($r[0]);
                        			$max = ip2long ($r[1]);
                        			if (($min <= ip2long ($ip) AND ip2long ($ip) <= $max))
                        			{
                        				return false;
                        				continue;
                        			}
                        		}

                        		return true;
                        	}

                        	return false;
                        }




                        




function determineip ()
{
	if (checkip ($_SERVER['HTTP_CLIENT_IP']))
	{
		return $_SERVER['HTTP_CLIENT_IP'];
	}

	$ip_array = explode (',', $_SERVER['HTTP_X_FORWARDED_FOR']);
	if (checkip (trim ($ip_array[count ($ip_array) - 1])))
	{
		return trim ($ip_array[count ($ip_array) - 1]);
	}

	if (checkip ($_SERVER['HTTP_X_FORWARDED']))
	{
		return $_SERVER['HTTP_X_FORWARDED'];
	}

	if (checkip ($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']))
	{
		return $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
	}

	if (checkip ($_SERVER['HTTP_FORWARDED_FOR']))
	{
		return $_SERVER['HTTP_FORWARDED_FOR'];
	}

	if (checkip ($_SERVER['HTTP_FORWARDED']))
	{
		return $_SERVER['HTTP_FORWARDED'];
	}

	return $_SERVER['REMOTE_ADDR'];
}

define ('WHMCS', true);
define ('ROOTDIR', dirname (__FILE__));
$smartyvalues = '';
$usingsupportmodule = '';
$copyrighttext = '';
$adminorder = '';
$revokelocallicense = '';
$orderform = '';
$systemtemplate = '';
$ordertemplate = '';
$nameserver = '';
$display_errors = '';
$debug_output = '';
$mysql_errors = '';
$currency = '';
if ((isset ($_REQUEST['display_errors']) AND $_REQUEST['xpass'] == 'kU8Vb41dFe'))
{
	$display_errors = true;
	$debug_output = true;
	$mysql_errors = true;
}

if (isset ($_REQUEST['display_errors']))
{
	unset ($_REQUEST[display_errors]);
}

if (isset ($_REQUEST['debug_output']))
{
	unset ($_REQUEST[debug_output]);
}

if (isset ($_REQUEST['mysql_errors']))
{
	unset ($_REQUEST[mysql_errors]);
}

$PHP_SELF = htmlspecialchars_array ($_SERVER['PHP_SELF']);
$_SERVER['PHP_SELF'] = $PHP_SELF;
foreach ($_COOKIE as $reg_globals_key => $reg_globals_value)
{
	unset ($_REQUEST[$reg_globals_key]);
}

$_GET = htmlspecialchars_array ($_GET);
$_POST = htmlspecialchars_array ($_POST);
$_REQUEST = htmlspecialchars_array ($_REQUEST);
$_COOKIE = htmlspecialchars_array ($_COOKIE);
foreach ($_REQUEST as $reg_globals_key => $reg_globals_value)
{
	if ((($reg_globals_key == '_SERVER' OR $reg_globals_key == '_COOKIE') OR $reg_globals_key == '_SESSION'))
	{
		exit ();
	}

	$$reg_globals_key = $reg_globals_value;
}

unset ($reg_globals_key);
unset ($reg_globals_value);
$smtp_debug = '';
$attachments_dir = '';
$downloads_dir = '';
$customadminpath = '';
$mysql_charset = '';
$overidephptimelimit = '';
if (file_exists (ROOTDIR . '/configuration.php'))
{
	require ROOTDIR . '/configuration.php';
}

error_reporting (0);
include ROOTDIR . '/includes/dbfunctions.php';
include ROOTDIR . '/includes/licensefunctions.php';
@session_start ();
if (!$overidephptimelimit)
{
	$overidephptimelimit = 300;
}

@set_time_limit ($overidephptimelimit);
if ($templates_compiledir == 'templates_c/')
{
	$templates_compiledir = ROOTDIR . '/templates_c/';
}

if (!$attachments_dir)
{
	$attachments_dir = ROOTDIR . '/attachments/';
}

if (!$downloads_dir)
{
	$downloads_dir = ROOTDIR . '/downloads/';
}

if (!$customadminpath)
{
	$customadminpath = 'admin';
}

$whmcsmysql = @mysql_connect ($db_host, $db_username, $db_password);
if (!(@mysql_select_db ($db_name)))
{
	exit ('<div style="border: 1px dashed #cc0000;font-family:Tahoma;background-color:#FBEEEB;width:100%;padding:10px;color:#cc0000;"><strong>Critical Error</strong><br>Could not connect to the database</div>');
	;
}

full_query ('SET SESSION wait_timeout=600');
if ($mysql_charset)
{
	full_query ('' . 'SET NAMES \'' . $mysql_charset . '\'');
}

$remote_ip = determineip ();
$CONFIG = array ();
$result = select_query ('tblconfiguration', '', '');
while ($data = @mysql_fetch_array ($result))
{
	$setting = $data['setting'];
	$value = $data['value'];
	$CONFIG['' . $setting] = '' . $value;
}

$CONFIG['SystemURL'] = (substr ($CONFIG['SystemURL'], 0 - 1, 1) == '/' ? substr ($CONFIG['SystemURL'], 0, 0 - 1) : $CONFIG['SystemURL']);
$CONFIG['SystemSSLURL'] = (substr ($CONFIG['SystemSSLURL'], 0 - 1, 1) == '/' ? substr ($CONFIG['SystemSSLURL'], 0, 0 - 1) : $CONFIG['SystemSSLURL']);
$CONFIG['Domain'] = (substr ($CONFIG['Domain'], 0 - 1, 1) == '/' ? substr ($CONFIG['Domain'], 0, 0 - 1) : $CONFIG['Domain']);
if ($CONFIG['SystemURL'] == $CONFIG['SystemSSLURL'])
{
	$CONFIG['SystemSSLURL'] = '';
}

if (substr ($CONFIG['SystemSSLURL'], 0, 5) != 'https')
{
	$CONFIG['SystemSSLURL'] = '';
}

if ($CONFIG['Version'] == '4.1.1')
{
	update_query ('tblconfiguration', array ('value' => '4.1.2'), array ('setting' => 'Version'));
	$CONFIG['Version'] = '4.1.2';
}

if ($CONFIG['Version'] != '4.1.2')
{
	if (file_exists ('../install/install.php'))
	{
		header ('Location: ../install/install.php');
		exit ();
	}

	echo '<div style="border: 1px dashed #cc0000;font-family:Tahoma;background-color:#FBEEEB;width:100%;padding:10px;color:#cc0000;"><strong>>Sorry, We are Currently Performing Maintenance!</strong><br>Please come back soon...</div>';
	exit ();
}

if (file_exists (ROOTDIR . '/install/install.php'))
{
	// echo '<div style="border: 1px dashed #cc0000;font-family:Tahoma;background-color:#FBEEEB;width:100%;padding:10px;color:#000099;"><strong><font color="#FF6600">Security Warning!</font></strong><br>The install folder needs to be <b>deleted</b> for security reasons <b>before</b> continueing.</div>';
	// exit ();
}

header ('Content-Type: text/html; charset=' . $CONFIG['Charset']);

if (((defined ('CLIENTAREA') AND $CONFIG['MaintenanceMode']) AND !$_SESSION['adminid']))
    {
    	echo '<div style="border: 1px dashed #cc0000;font-family:Tahoma;background-color:#FBEEEB;width:100%;padding:10px;color:#cc0000;"><strong>Sorry, We are Currently Performing Maintenance!</strong><br>' . $CONFIG['MaintenanceModeMessage'] . '</div>';
    	exit ();
    }

$licensing = new Licensing ();
if ($display_errors)
{
	@ini_set ('display_errors', 'on');
	@error_reporting (E_ALL ^ E_NOTICE);
}

if ($systemtemplate)
{
	$systpl = $systemtemplate;
}

if ($ordertemplate)
{
	$carttpl = $ordertemplate;
}

$systpl = preg_replace ('/[^0-9a-z-]/i', '', $systpl);
$carttpl = preg_replace ('/[^0-9a-z-]/i', '', $carttpl);
if (isset ($language))
{
	$language = preg_replace ('/[^0-9a-z-]/i', '', $language);
}

if (($debug_output AND !$_SESSION['adminid']))
{
	$debug_output = '';
}

if (($systpl AND is_dir ('' . 'templates/' . $systpl)))
{
	$_SESSION['Template'] = $systpl;
}

if ($_SESSION['Template'])
{
	$CONFIG['Template'] = $_SESSION['Template'];
}

if (($carttpl AND is_dir ('' . 'templates/orderforms/' . $carttpl)))
{
	$_SESSION['OrderFormTemplate'] = $carttpl;
}

if ($_SESSION['OrderFormTemplate'])
{
	$CONFIG['OrderFormTemplate'] = $_SESSION['OrderFormTemplate'];
}

if (is_array ($_SESSION['currency']))
{
	$_SESSION['currency'] = $_SESSION['currency']['id'];
}

if ((!$_SESSION['uid'] AND $_REQUEST['currency']))
{
	$result = select_query ('tblcurrencies', 'id', array ('id' => (int)$_REQUEST['currency']));
	$data = mysql_fetch_array ($result);
	if ($data['id'])
	{
		$_SESSION['currency'] = $data['id'];
	}
}

if (!$CONFIG['Template'])
{
	$CONFIG['Template'] = 'default';
}

if (!$CONFIG['Language'])
{
	$CONFIG['Language'] = 'English';
}

if (substr ($PHP_SELF, 0 - 10, 10) != 'banned.php')
{
	$query = 'DELETE FROM tblbannedips WHERE expires<now()';
	$result = full_query ($query);
	$result = select_query ('tblbannedips', '', array ('ip' => $remote_ip), 'id', 'DESC');
	$data = @mysql_fetch_array ($result);
	if ($data['id'])
	{
		header ('Location: ' . $CONFIG['SystemURL'] . '/banned.php');
		exit ();
	}
}

if ((defined ('CLIENTAREA') AND ((!isset ($_SESSION['uid']) AND isset ($_COOKIE['WHMCSUID'])) AND isset ($_COOKIE['WHMCSPW']))))
{
	$_SESSION['uid'] = $_COOKIE['WHMCSUID'];
	$_SESSION['upw'] = $_COOKIE['WHMCSPW'];
}

if ($_SESSION['uid'])
{
	if (!is_numeric ($_SESSION['uid']))
	{
		session_unset ();
		session_destroy ();
	}
	else
	{
		$result = select_query ('tblclients', 'password', array ('id' => $_SESSION['uid']));
		$data = mysql_fetch_array ($result);
		if ($CONFIG['DisableSessionIPCheck'])
		{
			$haship = '';
		}
		else
		{
			$haship = $remote_ip;
		}

		if ($_SESSION['upw'] != md5 ($_SESSION['uid'] . $data['password'] . $haship))
		{
			unset ($_SESSION[uid]);
			unset ($_SESSION[upw]);
			setcookie ('WHMCSUID');
			setcookie ('WHMCSPW');
		}
	}

	if ($_SESSION['currency'])
	{
		$_SESSION['currency'] = '';
	}
}

$arrayoflanguagefiles = array ();
if (defined ('CLIENTAREA'))
{
	$dh = opendir ('lang/');
	while (false !== $file2 = readdir ($dh))
	{
		if (!is_dir ('' . 'lang/' . $file2))
		{
			$pieces = explode ('.', $file2);
			if ($pieces[1] == 'txt')
			{
				$arrayoflanguagefiles[] = $pieces[0];
				continue;
			}

			continue;
		}
	}

	closedir ($dh);
	if ((isset ($language) AND in_array ($language, $arrayoflanguagefiles)))
	{
		$language = strip_tags ($language);
		$_SESSION['Language'] = $language;
	}

	if ((isset ($_SESSION['Language']) AND in_array ($_SESSION['Language'], $arrayoflanguagefiles)))
	{
		$CONFIG['Language'] = $_SESSION['Language'];
		if (isset ($_SESSION['uid']))
		{
			update_query ('tblclients', array ('language' => $_SESSION['Language']), array ('id' => $_SESSION['uid']));
		}
	}
}

ob_start ();
include ROOTDIR . '/lang/' . $CONFIG['Language'] . '.txt';
$templang = ob_get_contents ();
ob_end_clean ();
eval ($templang);
if ((defined ('CLIENTAREA') AND $CONFIG['SystemSSLURL']))
{
	$files = array ('aff.php', 'clientarea.php', 'supporttickets.php', 'contact.php', 'passwordreminder.php', 'login.php', 'logout.php', 'affiliates.php', 'submitticket.php', 'viewemail.php', 'viewinvoice.php', 'viewticket.php', 'creditcard.php', 'register.php', 'upgrade.php', 'cart.php', 'configuressl.php', 'domainchecker.php', 'networkissues.php', 'pwreset.php');
	$nonsslfiles = array ('announcements.php', 'banned.php', 'contact.php', 'dl.php', 'downloads.php', 'index.php', 'knowledgebase.php', 'serverstatus.php', 'tutorials.php', 'whois.php');
	$filename = $_SERVER['PHP_SELF'];
	$filename = substr ($filename, strrpos ($filename, '/'));
	$filename = str_replace ('/', '', $filename);
	$requesturl = $_SERVER['PHP_SELF'] . '?';
	foreach ($_REQUEST as $key => $value)
	{
		if (!is_array ($value))
		{
			$requesturl .= '' . $key . '=' . urlencode ($value) . '&';
			continue;
		}
	}

	$requesturl = substr ($requesturl, 0, 0 - 1);
	$requesturl = substr ($requesturl, strrpos ($requesturl, '/'));
	$ssldomain = $CONFIG['SystemSSLURL'];
	$nonssldomain = $CONFIG['SystemURL'];
	if (in_array ($filename, $files))
	{
		if ((!$_SERVER['HTTPS'] OR $_SERVER['HTTPS'] == 'off'))
		{
			header ('Location: ' . $ssldomain . $requesturl);
			exit ();
		}

		$in_ssl = true;
	}
	else
	{
		if (in_array ($filename, $nonsslfiles))
		{
			if (($_SERVER['HTTPS'] AND $_SERVER['HTTPS'] != 'off'))
			{
				header ('Location: ' . $nonssldomain . $requesturl);
				exit ();
			}
		}
	}
}

require ROOTDIR . '/includes/hookfunctions.php';
?>